package com.woniu.util;

import com.baomidou.mybatisplus.extension.api.R;
import com.woniu.entity.UserCart;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

//统一返回类
@Data
@NoArgsConstructor
@AllArgsConstructor
public class ResData<T> {
    private Integer code;
    private String msg;
    private T data;

    public ResData ok(){
        return new ResData(ResEnum.SUCCESS.getCode(),
                ResEnum.SUCCESS.getMsg(), null);
    }
    public ResData ok(T t){
        return new ResData(ResEnum.SUCCESS.getCode(),
                ResEnum.SUCCESS.getMsg(), t);
    }
    /**
     * @param msg 是生成的jwt，作为msg返回给前端
     * @Description 
     * @Return com.woniu.util.ResData
     * @Author dhx
     * @Date Create by 2023/11/16 12:02
     */
    public ResData ok(T t,String msg){
        return new ResData(ResEnum.SUCCESS.getCode(),
                msg, t);
    }
    public ResData fail(ResEnum resEnum){
        return new ResData(resEnum.getCode(),
                resEnum.getMsg(), null);
    }
    public ResData fail(T t,ResEnum resEnum){
        return new ResData(resEnum.getCode(),
                resEnum.getMsg(), t);
    }
}
